/**
 * API功能：配置用户、权限相关的API
 */
import axios from 'axios';
let token = localStorage.getItem('authorization');
axios.defaults.headers.common['Authorization'] = token;

var baseUrl = '/sys';

/**
 * 
 * @param {*} params
 * 临时使用
 * 
 */
// 人脸识别数据处理
export const registerUser = params => axios.post('/scan/face/register/base64', params);
// 人脸校验
export const checkUser = params => axios.post('/scan/face/compare/base64', params);

/**
 * 用户管理
 */
// 获取用户列表信息
export const getUserList = params => axios.get(`${baseUrl}/user/list`, { params: params });
// 重置密码
export const resetPwd = params => axios.put(`${baseUrl}/user/reset-password`, params);
// 新增用户
export const addUser = params => axios.post(`${baseUrl}/user/add`, params);
// 删除用户
export const deleteUser = params => axios.delete(`${baseUrl}/user/delete`, { params: params });
// 获取根据id查询用户详情
export const getUserDetails = params => axios.get(`${baseUrl}/user/details`, { params: params });
// 启用和停用
export const userToggle = params => axios.put(`${baseUrl}/user/toggle`, params);
// 更新
export const updateUser = params => axios.put(`${baseUrl}/user/update`, params);

/**
 * 角色管理
 */
// 获取角色管理列表
export const getRoleList = params => axios.get(`${baseUrl}/role/list`, { params: params });
// 新增角色
export const addRole = params => axios.post(`${baseUrl}/role/add`, params);
// 删除角色
export const deleteRole = params => axios.delete(`${baseUrl}/role/delete`, { params: params });
// 获取角色详情
export const getRoleDetails = params => axios.get(`${baseUrl}/role/details`, { params: params });
// 更新
export const updateRole = params => axios.put(`${baseUrl}/role/update`, params);
// 获取角色菜单管理权限列表
export const getRoleMenuList = params => axios.get(`${baseUrl}/role-menu/list`, { params: params });
// 角色菜单权限管理更新
export const updateRoleMenu = params => axios.put(`${baseUrl}/role-menu/save`, params);

// 获取用户角色关联
export const getUserRoleList = params => axios.get(`${baseUrl}/user-role/list`, { params: params });
// 保存用户角色关联配置
export const getUserRoleSave = params => axios.post(`${baseUrl}/user-role/save`, params);

// 获取用户事项关联（已配置）/user-item/item-list
export const getUserEventList = params => axios.get(`${baseUrl}/user-item/list`, { params: params });
// 获取用户事项关联（可选列表）
export const getEventList = params => axios.get(`${baseUrl}/user-item/item-list`, { params: params });
// 保存用户事项关联配置
export const getUserEventSave = params => axios.post(`${baseUrl}/user-item/save`, params);

// 获取用户组织机构关联数据
export const getUserOrgList = params => axios.get(`${baseUrl}/user-organize/list`, { params: params });
// 保存用户组织机构关联数据
export const getUserOrgSave = params => axios.post(`${baseUrl}/user-organize/save`, params);